
import { getSaToken, setSaToken, removeSaToken } from '@/utils/storage'
import { getUserInfo } from '@/api/user'
// import { Toast } from 'vant'
const state = {
  token: getSaToken(),
  userInfo: {}
}
const mutations = {
  setToken(state, payload) {
    state.token = payload
    setSaToken(payload)
  },
  removeToken(state) {
    state.token = {}
    removeSaToken()
  },
  setUserInfo(state, payload) {
    state.userInfo = payload
  }
}
const getters = {}
const actions = {
  async Actions_getUserInfo(context) {
    const res = await getUserInfo()
    context.commit('setUserInfo', res.data)
  }
}

export default {
  state,
  mutations,
  getters,
  actions,
  namespaced: true
}
